package org.jeecg.modules.api.order.mapper;

import java.math.BigDecimal;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.api.order.entity.Order;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
 * @Description: 分销订单
 * @Author: jeecg-boot
 * @Date:   2024-09-26
 * @Version: V1.0
 */
public interface OrderMapper extends BaseMapper<Order> {

    @Select("select ifnull(sum(team_fyamount),0) from fx_order where team_id=#{memberId} and create_time>=#{startTime} and create_time<=#{endTime}")
    BigDecimal getSumFyAmount(@Param("memberId") String memberId,@Param("startTime")String startTime,@Param("endTime")String endTime);

    @Select("select count(1) from (select count(1),user_id from fx_order where user_id in(select id from fx_member where recommend_id is not null and recommend_id!=0  and DATE_FORMAT(create_time,'%Y-%m')=#{time}) group by user_id) as t")
    int sumOrderUserCount(@Param("time") String time);
}
